﻿@model CodeStash.Models.Snippet.OpenFromWebViewModel
@using CodeStash.ExtensionsMethods

<div id="AjaxContents">

    <input id="successfulParse" type="hidden" value="@Model.CodeHasBeenParsed" />
    <input id="HighlightingCSSToUse" type="hidden" value="@Model.HighlightingCSS" />


    @using (Html.BeginForm("OpenFromWeb", "CodeSnippet", FormMethod.Post, new { id = "OpenFromWebForm" }))
    {

        @Html.AntiForgeryToken("OpenFromWeb")
        
        if (!Model.CodeHasBeenParsed)
        {
            <p>Fill in the form values below and click "Submit" to highlight a snippet from the web</p>
        
            <div class="headedPanel">
                <div id="openFromWebInner">

                    <strong>FileName</strong>
                    <div>
                        @Html.TextBoxFor((x) => x.FileName,
                            new Dictionary<string, object> { { "style", "width:400px" } })
                        &nbsp;
                        @Html.ValidationMessageFor((x) => x.FileName)
                    </div>
   		            <br />
                    <strong>Language</strong>
                    <div>
                    @Html.ComboFor(x => x.LanguageId, x => x.LanguageList, x => x.LanguageId, x => x.Language1, 
                        new Dictionary<string,object> { 
                            { "style", "width:400px"}, 
                            { "class", "selectBox"  }})
                    &nbsp;
                    @Html.ValidationMessageFor((x) => x.LanguageId)
                    </div>
                    <p>
                        <br />
                        <input id="Submit" type="button" value="Ok" />
                        <br />
                     </p>
                 </div>
            </div>
        
        }
        else
        {
            <p>The highlighted web snippet is shown below</p>
            <div class="snippet">
                <div class="highlightedSnippetHeader">
                </div>
                <div class="highlightedSnippet">
                    <pre class="@CodeStash.Utils.WebSiteUtils.GetCodeClass(Model.LanguageCode)">@Model.ActualCode.Trim()</pre>
                </div>
            </div>        
        }
    }
</div>
